
/*
 * @项目名称: 模板开发
 * @FilePath: /meek/src/utils/coordinate.js
 * @Author: 1106408264@qq.com
 * @Date: 2017-06-04T23:35:44+08:00
 * @LastEditors: 1106408264@qq.com
 * @LastEditTime: 2018-03-18T22:29:46+08:00
 * Copyright (c) 2018-2022
 */

/**
 * Created by zypc on 2017/6/4.
 */
export const Coordinate = {}

Coordinate.add = (coordinate, delta)  => {
  coordinate[0] += delta[0]
  coordinate[1] += delta[1]
  return coordinate
}


Coordinate.rotate = (coordinate, angle) => {
  const cosAngle = Math.cos(angle)
  const sinAngle = Math.sin(angle)
  const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle
  const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle
  coordinate[0] = x
  coordinate[1] = y
  return coordinate
}

Coordinate.scale = (coordinate, scale) => {
  coordinate[0] *= scale
  coordinate[1] *= scale
  return coordinate
}


export default {
  Coordinate
}
